﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MDSAdministration
{
    public class MDSHelper
    {
        static public MDSDataTypes GetMDSDataType(string TypeFullName)
        {
            switch (TypeFullName)
            {
                case Constants.SYSTEM_STRING:
                    return MDSDataTypes.String;
                case Constants.SYSTEM_DATETIME:
                    return MDSDataTypes.DateTime;
                case Constants.SYSTEM_DECIMAL:
                    return MDSDataTypes.Decimal;
                case Constants.SYSTEM_INT32:
                    return MDSDataTypes.Int32;
                default:
                    throw new Exception("Unknown DataType for column");
            }
        }

        static public MDSDataTypes GetMDSDataType(int DataTypeID)
        {
            switch (DataTypeID)
            {
                case Constants.DATA_TYPES_TEXT:
                    return MDSDataTypes.String;
                case Constants.DATA_TYPES_DATETIME:
                    return MDSDataTypes.DateTime;
                case Constants.DATA_TYPES_NUMBER:
                    return MDSDataTypes.Decimal;
                case Constants.DATA_TYPES_LINK:
                    return MDSDataTypes.Int32;
                default:
                    throw new Exception("Unknown DataType for column");
            }
        }

        static public string GetMDSNullValue(MDSDataTypes datatype, string MemberName)
        {
            if(MemberName.ToUpper() == Constants.NAME)
            {
                return Constants.MDS_STAGING_ENTITY_NULL;
            }

            switch (datatype)
            {
                case MDSDataTypes.String:
                    return "'" + Constants.MDS_STAGING_ENTITY_NULL_STRING + "'";
                case MDSDataTypes.DateTime:
                    return "'" + Constants.MDS_STAGING_ENTITY_NULL_DATETIME + "'";
                case MDSDataTypes.Decimal:
                    return Constants.MDS_STAGING_ENTITY_NULL_DECIMAL;
                case MDSDataTypes.Int32:
                    return Constants.MDS_STAGING_ENTITY_NULL_DECIMAL;
                default:
                    throw new Exception("Unknown DataType for column");
            }
        }
    }
}
